/* Copyright (C) 2001-2019 Peter Selinger.
   This file is part of Potrace. It is free software and it is covered
   by the GNU General Public License. See the file COPYING for details. */


#ifndef MAIN_H
#define MAIN_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "potracelib.h"
#include "progress_bar.h"
#include "auxiliary.h"
#include "trans.h"

/* structure to hold a dimensioned value */
struct dim_s {
  double x; /* value */
  double d; /* dimension (in pt), or 0 if not given */
};
typedef struct dim_s dim_t;

#define DIM_IN (72)
#define DIM_CM (72 / 2.54)
#define DIM_MM (72 / 25.4)
#define DIM_PT (1)

/* set some configurable defaults */

#ifdef USE_METRIC
#define DEFAULT_DIM DIM_CM
#define DEFAULT_DIM_NAME "centimeters"
#else
#define DEFAULT_DIM DIM_IN
#define DEFAULT_DIM_NAME "inches"
#endif

#ifdef USE_A4
#define DEFAULT_PAPERWIDTH 595
#define DEFAULT_PAPERHEIGHT 842
#define DEFAULT_PAPERFORMAT "a4"
#else
#define DEFAULT_PAPERWIDTH 612
#define DEFAULT_PAPERHEIGHT 792
#define DEFAULT_PAPERFORMAT "letter"
#endif

#ifdef DUMB_TTY
#define DEFAULT_PROGRESS_BAR progress_bar_simplified
#else
#define DEFAULT_PROGRESS_BAR progress_bar_vt100
#endif

/* structure to hold per-image information, set e.g. by calc_dimensions */
struct imginfo_s {
  int pixwidth;        /* width of input pixmap */
  int pixheight;       /* height of input pixmap */
  double width;        /* desired width of image (in pt or pixels) */
  double height;       /* desired height of image (in pt or pixels) */
  double lmar, rmar, tmar, bmar;   /* requested margins (in pt) */
  trans_t trans;        /* specify relative position of a tilted rectangle */
};
typedef struct imginfo_s imginfo_t;

/* backends and their characteristics */
struct backend_s {
	const char *name;       /* name of this backend */
	const char *ext;        /* file extension */
	int fixed;        /* fixed page size backend? */
	int pixel;        /* pixel-based backend? */
	int multi;        /* multi-page backend? */
	int(*init_f)(FILE *fout);                 /* initialization function */
	int(*page_f)(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo);
	/* per-bitmap function */
	int(*term_f)(FILE *fout);                 /* finalization function */
	int opticurve;    /* opticurve capable (true Bezier curves?) */
};
typedef struct backend_s backend_t;

#endif /* MAIN_H */
